import http from './request';

// 根据角色名称分页  获取角色列表
const roleList = (params: IRoleListParams): PRES<IRoleListModel> => http.get('role/list', { params });

// 获取所有角色    // role/listAll
const roleListAll = (): PRES<IRoleModel[]> => http.get('role/listAll');

// 修改角色状态    // role/updateStatus/{id}
const updateStatus = (id: number, status: number): PRES<any> => http.post(`role/updateStatus/${id}?status=${status}`);

// 添加角色     // role/create
const createRole = (params: IRoleModel): PRES<any> => http.post(`role/create`, params);

// 修改角色   // role/update/{id}
const updateRoleById = (params: IRoleModel): PRES<any> => http.post(`role/update/${params.id}`, params);

// 根据角色id 获取角色相关菜单   // role/listMenu/{roleId}
const getRoleMenuById = (roleId: number): PRES<IRoleMenuModel[]> => http.get(`role/listMenu/${roleId}`);

// 根据角色id 获取角色相关资源  // role/listResource/{roleId}
const getRoleResourceById = (roleId: number) => http.get(`role/listResource/${roleId}`);

// 给角色分配菜单  // role/allocMenu
// const roleAllotMenu = (params): PRES<any> => http.post(`role/allocMenu`);

// role/allocResource
// 给角色分配资源
// const roleAllotResource = (params): PRES<any> => http.post(`role/allocResource`);

// 导出
export {
  roleList,
  roleListAll,
  updateStatus,
  createRole,
  updateRoleById,
  getRoleMenuById,
  getRoleResourceById,
  // roleAllotMenu,
  // roleAllotResource,
}